package com.example.demo.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class ResponseMsg<T> {
    private int code;
    private String msg;
    private T data;


    public static ResponseMsg ok() {
        ResponseMsg response = new ResponseMsg(200, null, null);
        return response;
    }

    public static <T> ResponseMsg<T> ok(T data) {
        ResponseMsg response = new ResponseMsg(200, null, data);
        return response;
    }

    public static ResponseMsg error(String  msg) {

        return error(500,msg);
    }

    public static ResponseMsg error(int code,String  msg) {
        ResponseMsg response = new ResponseMsg(code, msg, null);
        return response;
    }
}
